package base.common;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Test2Map {

	public static void main(String[] args) {
		// HashMap
		Map<String, Integer> map = new HashMap<String, Integer>();
		for(int i=0; i<100; i++) {
			map.put("K" + i, i);
		}
		
		System.out.println("无序遍历打印");
		for(String key : map.keySet()) {
			System.out.println("map1 key:" + key + ", value: "+ map.get(key));
		}
		
		System.out.println("有序遍历打印");
		List<Object> keys = Arrays.asList(map.keySet().toArray());
		System.out.println(keys.getClass().getName());
		// LIST 自带的排序
		keys.sort(null);
		for(Object key : keys) {
			System.out.println("map2 key:" + key + ", value: "+ map.get(key));
		}
		
	}

}
